package jvm;

/**
 * VM 参数:  -XX:NewSize=5242880 -XX:MaxNewSize=5242880 -XX:InitialHeapSize=10485760 -XX:MaxHeapSize=10485760 -XX:SurvivorRatio=8 -XX:PretenureSizeThreshold=10485760 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log
 */
public class TestGc {
    private static final int _1MB = 1024 * 1024;

    // 占用内存，方便GC 查看日志更加明显
    private byte[] bytes = new byte[2 * _1MB];

    public Object ref;

    public static void main(String[] args) throws InterruptedException {
        TestGc t1 = new TestGc();
        TestGc t2 = new TestGc();
        t1.ref = t2;
        t2.ref = t1;

        t1 = null;
        t2 = null;

        System.gc();
    }
}
